﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using NpgsqlTypes;
using PcaCore.BOL.Tablas;
using System.Reflection;

namespace PcaCore.DAL.Tablas
{
    public class dTPais
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(dTPais));

        #region Public

        public static oTPais Get(string paisId)
        {
            try
            {
                //CREATE OR REPLACE FUNCTION pca_tablas.fn_get_pais(varchar --pais_id
                //          )RETURNS SETOF pca_tablas.paises
                return Core.GetObjectDb<oTPais>("pca_tablas.fn_get_pais",
                                                new oParametro(NpgsqlDbType.Varchar, paisId));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static List<oTPais> GetList(string filtro)
        {
            try
            {
                //CREATE OR REPLACE FUNCTION pca_tablas.fn_get_list_paises(varchar --nombre
                //            )RETURNS SETOF pca_tablas.paises
                return Core.GetListObjecstDb<oTPais>("pca_tablas.fn_get_list_paises",
                                                     new oParametro(NpgsqlDbType.Varchar, filtro));
            }
            catch (Exception ex)
            {
                throw Core.LogException(log, ex, MethodBase.GetCurrentMethod().Name);
            }
        }

        #endregion
    }
}
